﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Vmago.Models
{
    public class RepositoryShopDetails : IShopDetails 
    {
        private ShopDetailsDataContext ds;

        public RepositoryShopDetails()
        {
            ds = new ShopDetailsDataContext();
        }

        #region IShopDetails Members

        public IEnumerable<ShopDetail> getShopDetails(string ShopID)
        {
            IEnumerable<ShopDetail> c = null;
            try
            {
                c = from p in ds.ShopDetails
                    where p.shopID.Equals(ShopID)
                    select p;
            }
            catch (Exception ex)
            {
                ds.Dispose();
                Console.WriteLine("RepositoryShopDetails:getShopDetails" + ex);
            }

            return c;
        }

        public IEnumerable<ShopSubShop> getShopSubShop(string ShopID)
        {

            IEnumerable<ShopSubShop> c = null;
            try
            {
                c= from p in ds.ShopSubShops
                   where p.shopID.Equals(Convert.ToInt32(ShopID))
                   select p;
                 }
             catch (Exception ex)
            {
                ds.Dispose();
                Console.WriteLine("RepositoryShopDetails:getShopSubShop" + ex);
            }

            return c;
        }

        public IEnumerable<ShopImage> getShopImage(string ShopID)
        {
            IEnumerable<ShopImage> c = null;
            try
            {
                c = from p in ds.ShopImages
                    where p.shopID.Equals(ShopID.ToString())
                    select p;
            }
            catch (Exception ex)
            {
                ds.Dispose();
                Console.WriteLine("RepositoryShopDetails:getShopImage" + ex);
            }

            return c;
        }

        #endregion

        #region IShopDetails Members


        public IEnumerable<ShopPosition> getShopPosition(string ShopID)
        {
            IEnumerable<ShopPosition> c = null;
            try
            {
                c = from p in ds.ShopPositions
                    where p.shopID.Equals(ShopID)
                    select p;
            }
            catch (Exception ex)
            {
                ds.Dispose();
                Console.WriteLine("RepositoryShopDetails:getShopPosition" + ex);
            }

            return c;
        }

        #endregion
    }
}
